//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    enable:false,
    motto: 'Hello World',
    userInfo: {},
    userawardlist:[],
    servicesname:"",
    disable:true
  },
  //事件处理函数
  gotoLottery: function() {
    wx.switchTab({
      url: '../canvas/canvas'
    })
  },
  onShow: function () {


    var that = this
    //调用应用实例的方法获取全局数据
    // app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:wx.getStorageSync("scope")
      })
    wx.request({
      data:{
        token:wx.getStorageSync("token")
      },
      url: getApp().globalData.url +'/index/app/userawardlist',
      success:function(res){
        if(res.data.code==200){

          if(res.data.data.length==0){
            that.setData({
              disable:false,
      
                     })
         
          }
         
            that.setData({
              userawardlist: res.data.data,
              servicesname: res.data.maxPage,
           
            })
          

     

        }


      },fail: function(){
        wx.showModal({
          title: '提示',
          content: '网络请求失败',
        })
      }
    })

  
  },
  copy:function(){
      //微信号粘贴板
      var that=this;
    var servicesname = that.data.servicesname
    wx.setClipboardData({
      data: servicesname,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            // wx.showModal({
            //   showCancel: false,
            //   title: '提示',
            //   content: '微信号复制成功，请添加好友领取奖品',
            // })
          }
        })
      }
    })
  }

  
})
